// gcc test2.c slasyf_rk.c -o test2 -L /usr/local/kml/lib/kblas/omp -lkblas -L /usr/local/kml/lib -lkservice
// gfortran main.c -o main -L /usr/local/lapacke/lib -lrefblas -llapack -ltmglib -llapacke (如果要用kblas的话，删除-refblas，加上)-L /usr/local/kml/lib/kblas/omp -lkblas
// 2: gcc test2.c slasyf_rk2.c -o test2 -L /usr/local/lapacke/lib -lrefblas -llapack -ltmglib -llapacke
#include <stdio.h>
#include <stdlib.h>
#include <slasyf_rk.h>
#include <string.h>
#define LDA 10

int main(int argc, char *argv[])
{
    char UPLO;
    int INFO, KB, NB;
    const int N = 10;
    const int LDW = N;
    int IPIV[LDA];
    float E[LDA], W[LDW * LDW];
    float A[LDA * LDA] = {-5.86, 3.99, -5.93, -2.82, 7.69, 9.3, 9.2, 5, 4, 1.5,
                          0, 9.33, 3.13, -8.02, 5.43, 1.2, 7.2, 3, 2.3, -1.3,
                          0, 0, -5.22, -9.3, -5.59, 4.3, 2.2, 5.7, 4.9, -3.3,
                          0, 0, 0, -2.82, 4.42, 4.3, 4.2, 5.11, -4.22, 2.5,
                          0, 0, 0, 0, 6.22, 2.33, 6.2, 7.53, 8.42, 3.5,
                          0, 0, 0, 0, 0, 1.3, 4.2, 5.3, -3.2, -1.5,
                          0, 0, 0, 0, 0, 0, -9.2, 5.42, 4.78, 5.45,
                          0, 0, 0, 0, 0, 0, 0, 5.99, 2.35, 7.55,
                          0, 0, 0, 0, 0, 0, 0, 0, 3.2, 5.5,
                          0, 0, 0, 0, 0, 0, 0, 0, 0, 6.65};
    for (int i = 0; i < LDA; i++)
    {
        E[i] = 2;
        IPIV[i] = 2;
    }
    for (int i = 0; i < LDW * LDW; i++)
    {
        W[i] = 2;
    }
    UPLO = 'L';
    INFO = N;
    KB = 8;
    NB = 8;

    SLASYF_RK(UPLO, N, NB, KB, A, LDA, E, IPIV, W, LDW, INFO);
    /*
        printf("E:\n");
        for (int i = 0; i < LDA; i++)
        {
            printf("%.6f\t", E[i]);
        }

        printf("IPIV:\n");
        for (int i = 0; i < LDA; i++)
        {
            printf("%.6f\t", IPIV[i]);
        }
    */
    printf("result A\n");
    for (int i = 0; i < LDA; i++)
    {
        for (int j = 0; j < LDA; j++)
        {
            printf("%.2f\t", A[j * LDA + i]);
        }
        printf("\n");
    }

    return 0;
}
